package offer.tree;

/**
 * @author DengYuan2
 * @create 2021-03-02 19:23
 */
public class n_55_1 {
    public static void main(String[] args) {
        n_55_1 n = new n_55_1();
        TreeNode t1 = new TreeNode(5);
        TreeNode t2 = new TreeNode(3);
        TreeNode t3 = new TreeNode(7);
        TreeNode t4 = new TreeNode(2);
        TreeNode t5 = new TreeNode(4);
        TreeNode t6 = new TreeNode(6);
        TreeNode t7 = new TreeNode(8);
        t1.left=t2;
        t1.right=t3;
        t2.left=t4;
        t2.right=t5;
        t3.left=t6;
        t3.right=t7;
        int res = n.TreeDepth(t1);
        System.out.println(res);
    }

    public int TreeDepth(TreeNode root) {
        if (root==null){
            return 0;
        }
        return 1+Math.max(TreeDepth(root.left),TreeDepth(root.right));
    }
}
